package client.ui.panel;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.ImageObserver;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;


import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.Timer;

public class TitlePanel extends JPanel {
	private URL bg = getClass().getResource("title.jpg");
	private URL west = getClass().getResource("UnicornLeft.jpg");
	private URL east = getClass().getResource("UnicornRight.jpg");
	public ImageIcon icon,lUni,rUni;
	private Image img;
	private Timer timer;
	private String time;
	private JLabel t, left, middle, right;
	private Date date;
	private Calendar c;

	private ImageObserver imageO;
	public TitlePanel(){
		//date=new Date();
		//c=new Calendar();
		
		//c.setTime(date);
		icon= new ImageIcon(bg);
		lUni=new ImageIcon(west);
		rUni=new ImageIcon(east);
		left=new JLabel(lUni);
		right=new JLabel(rUni);
		middle=new JLabel(icon);
		setBackground(Color.WHITE);
		ClockListener cl=new ClockListener();
		timer = new Timer(100,cl);
		//right=new JLabel(new ImageIcon());
		time="Now Synching Time";
		imageO=icon.getImageObserver();
		img=icon.getImage();
		setLayout(new BorderLayout());
		t=new JLabel (time);
		add(t,BorderLayout.NORTH);
		add(right,BorderLayout.EAST);
		add(middle,BorderLayout.CENTER);
		add(left,BorderLayout.WEST);
		timer.start();
		
		setSize(700, 400);
		
	}
	
	
	
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		//imageO=icon.getImageObserver();
		//img=icon.getImage();
		//g.drawImage(img,0,0, imageO);
		
	}
	
	public class ClockListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			//time= new String(c.getTime().toString());
			t.setText(time);
			repaint();
		}
		
	}

}
